// @vitest-environment jsdom // // The [locale] mirror pages re-export the bare page and add getStaticPaths, // which tells `voltro build` which locale-prefixed paths to emit. The default // locale (en) is NOT listed — it lives at the bare path — so only /de is // produced. We also confirm each mirror re-exports the base page + its meta. import { describe, expect, test, vi } from 'vitest' // The mirrors transitively import the base pages, which import @voltro/i18n. // Stub it so importing the modules doesn't require the real i18n runtime. vi.mock('@voltro/i18n', () => ({ // The locale catalogs call these at module top-level; identity mirrors the // real (compile-time-only) implementations so importing them doesn't throw. defineCatalog: (c: T): T => c, defineLocale: () => (c: T): T => c, useLocale: () => 'en', useT: (id: string) => id, T: ({ id }: { id: string }) => id, })) const indexMirror = await import('./page') const aboutMirror = await import('./about/page') describe('home mirror — getStaticPaths', () => { test('emits only non-default locales (just /de)', async () => { const paths = await indexMirror.getStaticPaths() expect(paths).toEqual([{ params: { locale: 'de' } }]) }) test('re-exports the base page component + its meta function', () => { expect(typeof indexMirror.default).toBe('function') expect(indexMirror.meta({ locale: 'de' }).title).toBe('Start — Voltro i18n') }) }) describe('about mirror — getStaticPaths', () => { test('emits only non-default locales (just /de)', async () => { const paths = await aboutMirror.getStaticPaths() expect(paths).toEqual([{ params: { locale: 'de' } }]) }) test('re-exports the base page component + its meta function', () => { expect(typeof aboutMirror.default).toBe('function') expect(aboutMirror.meta({ locale: 'en' }).title).toBe('About — Voltro i18n') }) })